package d1130.r212.num27;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Tools {
    //平均分
    public static double getAvg(List<Student> stuList){
        //所有成绩的和
        double sum=0;
        for (Student s : stuList) {
           sum=sum+ s.getScore();

        }
        return sum/stuList.size();
    }
    //获得不及格学生
    public static List<Student> getScore(List<Student> list,double x,double y){
        List<Student> stus=new ArrayList<>();//把不及格学生放到stus集合中  60---70   70---80  左包含 ，右不包含
        Iterator<Student> it=list.iterator();
        while (it.hasNext()){//背下来
            Student stu=it.next();
            if (stu.getScore()>=x && stu.getScore()<y){
                stus.add(stu);
            }
        }
        return stus;


    }

}
